#ifndef __DBM_WRAPPER_H__
#define __DBM_WRAPPER_H__

#define SQL_CMD_MAX_LEN 2048 

typedef void* DB_CONN_HDL;
typedef void* DB_EXEC_RES;

int dbm_init(unsigned int max_conns);/* initialize connection pool */
int dbm_exit(void);/* deinitialize connection pool,free memory */
int dbm_connect(void); /* connect 'ipc' in 'ialarm911.net' use mysql-proxy */
int dbm_disconnect(void); /* disconnect the connection in the caller routine */
int dbm_print_table(const char *tblname);
/* connect database in the caller routine */
int dbm_connect2(const char *host,unsigned short port,const char *db,const char *username,const char *pwd);

typedef int(*HANDLE_SQL_CB)(DB_EXEC_RES result,void *user_data, int size);
/* order: the sql result-set sequency number,start from 1 */
typedef int(*HANDLE_MSQL_CB)(DB_EXEC_RES result,int order,void *user_data, int size);

int dbm_cmd_handle(const char *sql,HANDLE_SQL_CB func);
int dbm_cmd_handle2(const char *sql,HANDLE_SQL_CB func,void *user_data,int size);
int dbm_cmd_handle3(const char *sql,HANDLE_MSQL_CB func,void *user_data,int size);

#endif
